home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Classes / DE_SerialSolutions2.0 / ModemExample / ModemTest.m < prev    next >
Encoding:
Text File  |  1992-08-19  |  1.3 KB  |  49 lines

  1. #import "../SerialAndModem2.0/Modem.h"
  2. #import <stdio.h>
  3. #import <sys/file.h>
  4. //
  5. //Note that you cannot use the set notify methods here since
  6. //there is no connection to the applkit.
  7. //
  8. main()
  9. {
  10. int ok;
  11. id    theModem;
  12.  
  13.     theModem = [[Modem alloc] init];
  14.     
  15.      ok = [theModem openRAW:"/dev/cufa" Baudrate:1200];
  16.     [theModem setParity:NONE];
  17.     ok = [theModem modemReset];
  18.     if( ok == SERIALOK)
  19.     {
  20.             printf("calling modem dial\n");
  21.             ok = [theModem modemDial:"276,7859" AutoBaud:YES];
  22.             fprintf(stderr,"Modem returns %i\n",ok);
  23.             fprintf(stderr,"modem status = %i\n",[theModem getModemStatus]);
  24.             switch ( [theModem getModemStatus])
  25.             {
  26.                 case IDLE:
  27.                     fprintf(stderr,"Modem IDLE\n");
  28.                     [theModem  modemHangup];
  29.                     break;
  30.                 case CONNECTED: //put your connected stuff here
  31.                     //if autobaud was yes then the port speed MAY have changed..
  32.                     fprintf(stderr,"Modem CONNECTED\n");
  33.                     fprintf(stderr,"last response from modem was\n",[theModem getLastResponse]);
  34.                     fprintf(stderr,"the modems speed is %i\n",[theModem baudrate]);
  35.                     break;
  36.                 case BUSY:
  37.                     fprintf(stderr,"Modem BUSY\n");
  38.                     [theModem  modemHangup];
  39.                     break;
  40.                 case NOCARRIER:
  41.                     fprintf(stderr,"Modem NOCARRIER\n");
  42.                     break;
  43.                 default:
  44.                     fprintf(stderr,"last response from modem was\n",[theModem getLastResponse]);
  45.             }
  46.     }
  47.     [theModem closePort];
  48. }
  49.